﻿<%@ Page Language="c#" CodeBehind="Index.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.Login.IndexPage" %>

<html>
<head>
  <title>OA系统</title>
  <style type="text/css">
    body
    {
      background-color: #14386a;
      margin: 0;
      padding: 0;
    }
    .Vibox
    {
      border-right: 0px;
      padding-right: 0px;
      border-top: 0px;
      padding-left: 0px;
      font-size: 12px;
      padding-bottom: 0px;
      margin: 0px;
      border-left: 0px;
      width: 150px;
      color: #003399;
      padding-top: 0px;
      border-bottom: 0px;
      font-style: normal;
      font-family: "Arial" , "Helvetica" , "sans-serif";
      height: 18px;
    }
    .Vibutton
    {
      border-right: #006699 1px solid;
      padding-right: 1px;
      border-top: #006699 1px solid;
      padding-left: 1px;
      font-size: 12px;
      padding-bottom: 1px;
      margin: 1px;
      border-left: #006699 1px solid;
      width: 60px;
      color: #006699;
      padding-top: 1px;
      border-bottom: #006699 1px solid;
      font-family: "宋体";
      height: 18px;
      background-color: #ffffff;
    }
    .Vitext
    {
      font-size: 12px;
      color: white;
      font-family: "宋体";
    }
    .Mybuttona
    {
      background-image: url(../../Images/denglu.jpg);
      cursor: pointer;
      width: 81px;
      height: 30px;
      margin: 0 4px;
      border-width: 0px;
    }
    .Mybuttonb
    {
      background-image: url(../../Images/quxiao.jpg);
      cursor: pointer;
      width: 81px;
      height: 30px;
      margin: 0 4px;
      border-width: 0px;
    }
    .face_table
    {
      width: 1024px;
      height: 768px;
      background: #2876C7 url(../../Images/newface1.jpg) no-repeat left top;
    }
    .buttonlabel
    {
      font-family: 黑体;
      font-size: 12pt;
      color: #fff;
      width: 70px;
      display: inline-block;
      text-align: left;
    }
  </style>
  <script type="text/javascript">
    //<!--
    function page_load() {
      if (document.getElementById("txtUsername").value == '')
        document.getElementById("txtUsername").focus();
      else
        document.getElementById("txtPassword").focus();
    }
    //-->
  </script>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body onload="page_load()">
  <div style="display: none;">
    <span id="obj">&nbsp;</span>
  </div>
  <script language="javascript" type="text/javascript">
    //<!--
    // 判断用户是否选择使用USBKey
    function needUsbKey() {
      try {
        var cb = document.getElementById("cb_isNeedUsbKey");
        if (cb !== null && cb.checked == true) {
          document.getElementById("obj").innerHTML = "<OBJECT id='ePass' style='LEFT: 0px; TOP: 0px' height='0' width='0' classid='clsid:E740C5DF-3454-46A7-80EC-364D1ADB6CF0' name='ePass' VIEWASTEXT></OBJECT>";
        }
        return true;
      } catch (err) {
        alert("ERROR: " + err.message);
        return false;
      }
    }
    //-->
  </script>
  <script language="VBScript" type="text/vbscript">

Dim FirstDigest
Dim Digest 
Digest= "01234567890123456"
dim bErr

'sub needUsbKey()
'	if  index.cb_isNeedUsbKey.checked =true Then
'		obj.innerHTML="<OBJECT id='ePass' style='LEFT: 0px; TOP: 0px' height='0' width='0' classid='clsid:E740C5DF-3454-46A7-80EC-364D1ADB6CF0' name='ePass' VIEWASTEXT></OBJECT>"
'	end if
'End sub

sub ShowErr(Msg)
	bErr = true
	ErrMsg.innerHTML = "<input type='hidden' name='ErrMsg' Value='" & Msg & "'>"
'	MsgBox Msg,0,"提示"
'	Document.Writeln "<FONT COLOR='#FF0000'>"
'	Document.Writeln "<P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P><P ALIGN='CENTER'><B>ERROR:</B>"
'	Document.Writeln "<P>&nbsp;</P><P ALIGN='CENTER'>"
'	Document.Writeln Msg
'	Document.Writeln " failed, and returns 0x" & hex(Err.number) & ".<br>"
'	Document.Writeln "<P>&nbsp;</P><P>&nbsp;</P><P>&nbsp;</P>"
'	Document.Writeln "</FONT>"
End Sub

function Validate()
	Digest = "01234567890123456"
	On Error Resume Next
	'Dim TheForm
	'Set TheForm = Document.forms("ValidForm")
	'If Len(TheForm.UserPIN.Value) < 4  Then
	'	MsgBox "PIN empty or user pin length less than 4 or so pin length less than 6!!"	 
	'	Validate = FALSE
	'	Exit Function
	'End If

	bErr = false

	'Let detecte whether the ePass 1000 Safe Active Control loaded.
	'If we call any method and the Err.number be set to &H1B6, it 
	'means the ePass 1000 Safe Active Control had not be loaded.
	ePass.GetLibVersion
	
	If Err.number = &H1B6 Then

		ShowErr "Load ePass 1000 Safe Active Control"
		Validate = false
		Exit function
	Else
		
		ePass.OpenDevice 1, ""
		
		If Err then
			ShowErr "请勾选使用框,并插入USB_Key!"
			Validate = false
			ePass.CloseDevice
			Exit function
		End if
	
		'ePass.ResetSecurityState 0
		dim results
		results = "01234567890123456"
		results = ePass.GetStrProperty(7, 0, 0)
		'MsgBox results

		'ePass.VerifyUserPIN TheForm.Identity.Value, TheForm.UserPIN.Value
		'ePass.VerifyPIN 0, TheForm.UserPIN.Value

		If Err Then
			ShowErr "Verify User PIN Failure!!!"
			Validate = false
			ePass.CloseDevice
			Exit function
		End If
		

		If Not bErr Then
			ePass.ChangeDir &H300, 0, "ASP_DEMO"
			If Err then 
				ShowErr "Change to demo directory"
				Validate = false
				ePass.CloseDevice
				Exit function
			End If
		End If


		'Open the first key file.
		If Not bErr Then
			ePass.OpenFile 0, 1
			If Err Then
				ShowErr "Open first KEY-file"
				Validate = false
				ePass.CloseDevice
				Exit function
			End If
		
		End If

		'Do HASH-MD5-HMAC compute.
		If Not bErr Then
			Digest = ePass.HashToken (1, 2,"<%=RandData%>")
			If Err Then 
				ShowErr "HashToken compute"
				Validate = false
				ePass.CloseDevice
				Exit function
			End If
			DigestID.innerHTML = "<input type='hidden' name='Digest' Value='" & Digest & "'>"
			snID.innerHTML = "<input type='hidden' name='SN_SERAL' Value='" & results & "'>"
		End If		
	End If

	ePass.CloseDevice
	
End function
  </script>
  <form id="index" method="post" runat="server" onsubmit="Validate()">
  <span id="DigestID"></span><span id="snID"></span><span id="ErrMsg"></span>
  <table class="face_table" cellspacing="0" cellpadding="0">
    <tr>
      <td width="443">
        &nbsp;
      </td>
      <td width="357" align="center" valign="top">
        <div style="height: 310px;">
          &nbsp;
        </div>
        <p>
          <!--img border="0" src="../../Images/welcome.gif" width="224" height="117"-->
        </p>
        <p>
          <span class="buttonlabel">用户名：</span><asp:TextBox ID="txtUsername" runat="server" CssClass="Vibox" /><asp:RequiredFieldValidator ID="rfvUsername" runat="server" ControlToValidate="txtUsername" ErrorMessage="*" />
        </p>
        <p>
          <span class="buttonlabel">密 码：</span><asp:TextBox ID="txtPassword" runat="server" CssClass="Vibox" TextMode="Password" /><asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword" ErrorMessage="*" />
        </p>
        <p>
          <asp:Button ID="btnSubmit" runat="server" CssClass="Mybuttona" Text="" />
          <input class="Mybuttonb" type="reset" value="" name="Submit2">
        </p>
        <p>
          <span class="Vitext">
            <asp:CheckBox ID="cb_isNeedUsbKey" runat="server" Text="使用USB_Key" Height="10px" Enabled="false" Visible="false" /><asp:Label ID="lblErrorMessage" runat="server" Visible="False" ForeColor="Red" Width="128px">错误的用户名和口令</asp:Label>
          </span>
        </p>
        <p>
          <span style="color: #fff;">建议在1024*768分辨率下浏览</span>
        </p>
      </td>
    </tr>
  </table>
  </form>
</body>
</html>
